﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenChart.Entities;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;

using OpenChart.PublicUnits;

namespace OpenChart.DrawChart
{
    class DrawingLogarithmAreaChart:DrawingLogarithmLineChart
    {
        /// <summary>
        /// 绘制数据
        /// </summary>
        protected override void DrawData()
        {
            base.DrawData();
        }

        /// <summary>
        /// 绘制Series
        /// </summary>
        /// <param name="item">Series</param>
        protected override void DrawOneSeries(Series item)
        {
            List<PointF> points = new List<PointF>();
            PointF tempPoint;
            double tempXValue, tempYValue;
            foreach (DataRow row in this.ChartArea.Data.Rows)
            {
                tempXValue = ChartHelper.GetDoubleValue(row[this.ChartArea.XValueMember], this.ChartArea.AxisX.IntervalType);
                tempYValue = ChartHelper.GetDoubleValue(row[item.YValueMember], this.ChartArea.AxisY1.IntervalType);
                tempPoint = this.GetPoint(tempXValue, tempYValue);
                points.Add(tempPoint);
            }
            if (points.Count() > 0)
            {
                points.Add(new PointF(points.Last().X, this.CanvasHeight - CON_DOWN_RANGE));
                points.Add(new PointF(points.First().X, this.CanvasHeight - CON_DOWN_RANGE));
                GraphicsPath path = new GraphicsPath();
                path.AddLines(points.ToArray());
                Brush brush = new SolidBrush(Color.FromArgb(128, item.Color));
                this.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                this.Graphics.FillPath(brush, path);
                this.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
            }
        }
    }
}
